package ATM;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * 菜单
 */
public class MenuPanel extends JPanel {
    private JButton searchBtn = new JButton(new ImageIcon("src/ATM/image/buttonFind.jpg"));
    private JButton getBtn = new JButton(new ImageIcon("src/ATM/image/buttonGet.jpg"));
    private JButton changePwdBtn = new JButton(new ImageIcon("src/ATM/image/buttonModify.jpg"));
    private JButton saveBtn = new JButton(new ImageIcon("src/ATM/image/buttonSave.jpg"));
    private JButton transferBtn = new JButton(new ImageIcon("src/ATM/image/buttonRegister.jpg"));
    private JButton endBtn = new JButton(new ImageIcon("src/ATM/image/buttonOff.jpg"));
    public MenuPanel(ATMFrame atm){

        this.setLayout(null);
        this.setOpaque(false);

        searchBtn.setBounds(0,100,140,50);
        searchBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                atm.getSearchPanel().showBlance(atm.getUsers().get(atm.getIndex()).getBlance());
                atm.showPanel("search");
            }
        });
        saveBtn.setBounds(0,300,140,50);
        saveBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                atm.getSavePanel().Refresh();
                atm.showPanel("save");
            }
        });
        getBtn.setBounds(0,500,140,50);
        getBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                atm.getGetPanel().Refresh();
                atm.showPanel("get");
            }
        });
        transferBtn.setBounds(884,100,140,50);
        transferBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                atm.getTransferPanel().Refresh();
                atm.showPanel("transfer");
            }
        });
        changePwdBtn.setBounds(884,300,140,50);
        changePwdBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                atm.getChangePwdPanel().Refresh();
                atm.showPanel("changePwd");
            }
        });
        endBtn.setBounds(884,500,140,50);
        endBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                atm.getLoginPanel().Refresh();
                atm.showPanel("login");
            }
        });


        this.add(searchBtn);
        this.add(saveBtn);
        this.add(getBtn);
        this.add(transferBtn);
        this.add(changePwdBtn);
        this.add(endBtn);





    }


}
